﻿

$(function () {
    $('#topmenu').click(function () {
        //alert(0)
        $('.mint-actionsheet').show();
        $('.v-modal').show();




    })

    $('#searchBtn').click(function () {
        //alert(1)
        get_list(1);
        return false;

    })

    $('.mint-actionsheet-listitem').click(function () {
        $('.mint-actionsheet').hide();
        $('.v-modal').hide();
        var t = $(this).text();

        $('#topmenu span').html(t);

        type = $(this).attr('data-type');
        get_list(1);
    })

    get_list(1);
})
var limit = 1;
var type = 0;
var orderId = '';
function get_list(ty) {

    if (ty == 1) {
        $(".mint-loadmore-content").html('');
        limit = 1;
    } else {
        $("#list_more").html('<div class="dropload-refresh"  onclick="get_list(0);">卖命加载中...</div>');
    }

    $.ajax({
        type: "post",
        url: "/agentcenter/orderpost",
        data: {
            limit: limit,
            type: type,
            orderId: $('#searchInput').val()
        },
        dataType: "json",
        success: function (data) {

            if (data.State) {
                var list = data.Datas;
                var content = '';
                for (var i = 0; i < list.length; i++) {

                    //content += '<li class="content-row fadeIn-Anim clearfix" data-id="' + list[i]['numid'] + '">';
                    //content += '<div class="goods">';
                    ////content += ' <img class="thumb" src="' + list[i]['picurl'] + '" />';
                    //content += '<div>';
                    //content += '<h3>' + list[i]['ProductDes'] + '</h3>';
                    //content += '<p>订单状态：<strong style="color:#ea3b4c;">' + list[i]['OrderStateDes'] + '</strong></p>';
                    //content += '<p>交易时间：' + formatDate(list[i]['CreateDate'].replace("/Date(", "").replace(")/", "")) + '</p>';
                    //content += '<p>订单号：' + list[i]['OrderID'] + '</p>';
                    //content += ' </div>';
                    //content += ' </div>';
                    //content += '<ul class="account">';
                    //content += ' <li><span>￥' + list[i]['PayPrice'] + '</span><label>付款金额</label></li>';
                    ////content +='  <li><span>￥'+list[i]['xgyg']+'</span><label>付款佣金</label></li>';
                    //content += '  <li><span class="price">￥' + list[i]['EffectPrediction'] + '</span><label>预估结算</label></li>';
                    //content += '  </ul>';
                    //content += ' </li>';



                    content += '<div class="box">';
                    content += '<div class="box-top">';
                    content += '<div class="goods-title">' + list[i]['ProductDes'] + '</div>';
                    content += ' <div class="shops-name">所属店铺:' + list[i]['ShopName'] + '</div>';
                    content += '<div class="time">创建:' + list[i]['CreateDate'] + '</div>';
                    //content += ' <div class="order-status fail">';
                    //content += '<span style="display: none;">已付款</span> <span style="display: none;">已结算</span> <span>' + list[i]['OrderStateDes'] + '</span>' + list[i]['OrderStateDes'] + '';
                    //content += '</div>';
                    if (list[i]['OrderStateDes'] == '订单失效') {
                        content += ' <div class="order-status fail">';
                        content += '<span>' + list[i]['OrderStateDes'] + '</span>';
                        content += '</div>';
                    } else if (list[i]['OrderStateDes'] == '订单结算') {
                        content += ' <div class="order-status settle">';
                        content += '<span>' + list[i]['OrderStateDes'] + '</span>';
                        content += '</div>';

                    } else if (list[i]['OrderStateDes'] == '订单付款' || list[i]['OrderStateDes'] == '订单成功') {
                        content += ' <div class="order-status pay">';
                        content += '<span>' + list[i]['OrderStateDes'] + '</span>';
                        content += '</div>';
                    }



                    content += '</div>';
                    content += '<div class="box-middle">';
                    content += '<div class="item">';
                    content += '<div class="money-title">付款金额</div>';
                    content += '<div class="money" style="font-size: 0.8rem;">￥' + list[i]['PayPrice'] + '</div>';
                    content += '</div>';
                    content += '<div class="item">';
                    content += '<div class="money-title">佣金</div>';
                    content += '<div class="money" style="font-size: 18px;  font-weight: bold; color: #fe4f3f;">￥' + list[i]['EffectPrediction'] + '</div>';
                    content += '</div>';
                    content += '</div>';
                    content += '<div class="box-bottom"><span>订单编号:</span>' + list[i]['OrderID'] + '</div>';
                    content += '</div>';



                }
                $(".mint-loadmore-content").append(content);

                if (list.length <=0) {
                    $(".mint-loadmore-content").append('<div class="dropload-refresh">没有更多记录！</div>');
                } 
                limit++;




                //waterfall();
                //lazy_img();
            } else if (data.State == 2) {
                $("#list_more").html('<div class="dropload-refresh">没有更多记录！</div>');
                //dialog("没有更多记录！");
                //$("#list_more").fadeOut(500);

            } else {
                $("#list_more").html('<div class="dropload-refresh">没有更多记录！</div>');
                //dialog("没有更多记录！！");
                //$("#list_more").fadeOut(500);
            }
        },
        error: function (xhr, type) {

        }
    });


}
function formatDate(nS) {
    return new Date(parseInt(nS)).toLocaleString().replace(/年|月/g, "-").replace(/日/g, " ");
}

//==============自动加载=============
//获取滚动条当前的位置
function getScrollTop() {
    var scrollTop = 0;
    if (document.documentElement && document.documentElement.scrollTop) {
        scrollTop = document.documentElement.scrollTop;
    }
    else if (document.body) {
        scrollTop = document.body.scrollTop;
    }
    return scrollTop;
}

//获取当前可是范围的高度
function getClientHeight() {
    var clientHeight = 0;
    if (document.body.clientHeight && document.documentElement.clientHeight) {
        clientHeight = Math.min(document.body.clientHeight, document.documentElement.clientHeight);
    }
    else {
        clientHeight = Math.max(document.body.clientHeight, document.documentElement.clientHeight);
    }
    return clientHeight;
}

//获取文档完整的高度
function getScrollHeight() {
    return Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
}


$(window).scroll(function () {
    if (getScrollTop() + getClientHeight() == getScrollHeight()) {
        //alert("到达底部");
        get_list(0);
    }
});

//==============自动加载=============
